﻿using Nebular.ExpenseManagement.Infrastructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Nebular.ExpenseManagement.Infrastructure.Test
{
    
    
    /// <summary>
    ///This is a test class for batch_JobQueueTest and is intended
    ///to contain all batch_JobQueueTest Unit Tests
    ///</summary>
    [TestClass()]
    public class batch_JobQueueTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

      
    

        /// <summary>
        ///A test for batch_JobQueue Constructor
        ///</summary>
        [TestMethod()]
        public void batch_JobQueueConstructorTest()
        {
            batch_JobQueue target = new batch_JobQueue();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }

        [TestMethod()]
        public void batch_jobQueueuAddRecord()
        {
            bool succes = true;
            using (BatchDataContext batchContext = new BatchDataContext("Data Source=msdbb4.surftown.dk;Initial Catalog=nebular_invoices;Persist Security Info=True;User ID=Nebular_admin;Password=maserati"))
            {//get infrastructure object.


                try
                {
                    batch_JobQueue job = new batch_JobQueue();

                    job.Id = Guid.NewGuid();
                    job.JobName = "test job";
                    job.State = "test";
                    DateTime date = System.DateTime.Now;
                    job.Created = date;
                    job.Modified = date;


                    batchContext.batch_JobQueues.InsertOnSubmit(job);

                    batchContext.SubmitChanges();
                }
                catch (Exception ex)
                {
                    succes = false;
                    System.Console.WriteLine("error caught");
                    System.Console.WriteLine(ex.ToString());


                }

                Assert.IsTrue(succes);

                
              

            }

        }
    }
}
